﻿using System.Collections.Generic;
using System.Web.Mvc;

namespace mvcfluentcontrols.Controls
{
    public class SmartBox : FluentHtmlString<SmartBox>
    {
        public SmartBox(string name)
            : base(name)
        {
            AddHtmlAttribute("ctype", "smartbox");
        }

        public SmartBox ServiceUrl(string url)
        {
            AddHtmlAttribute("serviceUrl", url);
            return this;
        }

        public SmartBox LookupType(string typename)
        {
            AddHtmlAttribute("lookupType", typename);
            return this;
        }

        public SmartBox MinLength(int value)
        {
            AddHtmlAttribute("minLength", value.ToString());
            return this;
        }

        public SmartBox CacheLength(string cacheLength)
        {
            AddHtmlAttribute("cacheLength", cacheLength);
            return this;
        }

        public SmartBox DelayDuration(string delayDuration)
        {
            AddHtmlAttribute("delayDuration", delayDuration);
            return this;
        }
        public SmartBox LangID(int langID)
        {
            AddHtmlAttribute("langID", langID.ToString());
            return this;
        }

        public override string ToHtmlString()
        {
            TagBuilder input = new TagBuilder("input");
            foreach (KeyValuePair<string, string> item in HtmlAttributes)
            {
                input.Attributes.Add(item);
            }

            return input.ToString(TagRenderMode.Normal);
        }
    }
}